home *** CD-ROM | disk | FTP | other *** search
/ All for Cell Phones: Sony Ericsson / Sony-Ericsson 2004.iso / Java / Holy Moley / HolyMoley.jar / HC.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-09-28  |  2.6 KB  |  154 lines

  1. import java.io.IOException;
  2. import java.util.Random;
  3. import javax.microedition.lcdui.Canvas;
  4. import javax.microedition.lcdui.Graphics;
  5. import javax.microedition.lcdui.Image;
  6.  
  7. // $FF: renamed from: HC
  8. public class class_0 extends Canvas {
  9.    private static Random rand = new Random();
  10.    // $FF: renamed from: m1 Mogura
  11.    private Mogura field_0 = new Mogura(1);
  12.    // $FF: renamed from: m2 Mogura
  13.    private Mogura field_1 = new Mogura(2);
  14.    // $FF: renamed from: m3 Mogura
  15.    private Mogura field_2 = new Mogura(3);
  16.    // $FF: renamed from: ml int
  17.    private int field_3;
  18.    private int life;
  19.    static int score;
  20.    static int stnum;
  21.    static boolean playSt;
  22.    static boolean gameover;
  23.    Image mmo;
  24.    // $FF: renamed from: hg javax.microedition.lcdui.Image
  25.    Image field_4;
  26.  
  27.    public class_0() {
  28.       try {
  29.          this.mmo = Image.createImage("/minimogu.png");
  30.          this.field_4 = Image.createImage("/heart.png");
  31.       } catch (IOException var1) {
  32.       }
  33.  
  34.    }
  35.  
  36.    public void hit(int var1) {
  37.       Object var2 = null;
  38.       Mogura var3;
  39.       if (var1 == 1) {
  40.          var3 = this.field_0;
  41.       } else if (var1 == 2) {
  42.          var3 = this.field_1;
  43.       } else {
  44.          var3 = this.field_2;
  45.       }
  46.  
  47.       if (var3.returnMmove() <= 6 && var3.returnMmove() > 1) {
  48.          if (var3.hanaSt()) {
  49.             if (score > 50) {
  50.                score -= 50;
  51.             }
  52.  
  53.             this.life -= 2;
  54.             this.field_3 += 2;
  55.          } else {
  56.             score += 10;
  57.             --this.field_3;
  58.          }
  59.  
  60.          var3.hit();
  61.       }
  62.  
  63.    }
  64.  
  65.    public void init() {
  66.       score = 0;
  67.       stnum = 0;
  68.       playSt = false;
  69.    }
  70.  
  71.    public void keyPressed(int var1) {
  72.       int var2 = ((Canvas)this).getGameAction(var1);
  73.       switch (var2) {
  74.          case 2:
  75.             this.hit(1);
  76.             return;
  77.          case 3:
  78.          case 4:
  79.          default:
  80.             return;
  81.          case 5:
  82.             this.hit(3);
  83.             return;
  84.          case 6:
  85.             this.hit(2);
  86.       }
  87.    }
  88.  
  89.    public synchronized void paint(Graphics var1) {
  90.       if (this.life < 1) {
  91.          gameover = true;
  92.          playSt = false;
  93.       }
  94.  
  95.       if ((rand.nextInt() >>> 1) % 100 < 40 && !this.field_0.isMove()) {
  96.          this.field_0.start(stnum);
  97.       }
  98.  
  99.       if ((rand.nextInt() >>> 1) % 100 < 40 && !this.field_1.isMove()) {
  100.          this.field_1.start(stnum);
  101.       }
  102.  
  103.       if ((rand.nextInt() >>> 1) % 100 < 40 && !this.field_2.isMove()) {
  104.          this.field_2.start(stnum);
  105.       }
  106.  
  107.       var1.setColor(16777215);
  108.       var1.fillRect(9, 4, 90, 40);
  109.       this.field_0.paint(var1);
  110.       this.field_1.paint(var1);
  111.       this.field_2.paint(var1);
  112.       if (this.field_0.returnMmove() == 7 && !this.field_0.hanaSt()) {
  113.          --this.life;
  114.       }
  115.  
  116.       if (this.field_1.returnMmove() == 7 && !this.field_1.hanaSt()) {
  117.          --this.life;
  118.       }
  119.  
  120.       if (this.field_2.returnMmove() == 7 && !this.field_2.hanaSt()) {
  121.          --this.life;
  122.       }
  123.  
  124.       var1.setColor(0);
  125.       var1.drawString("Score : " + score, 30, 5, 20);
  126.       var1.drawImage(this.field_4, 10, 19, 20);
  127.       var1.drawString(" x " + this.life, 23, 19, 20);
  128.       var1.drawImage(this.mmo, 60, 19, 20);
  129.       var1.drawString(" x " + this.field_3, 73, 19, 20);
  130.       if (this.field_3 < 1) {
  131.          playSt = false;
  132.       }
  133.  
  134.    }
  135.  
  136.    public int returnH() {
  137.       return this.life;
  138.    }
  139.  
  140.    public int returnS() {
  141.       return score;
  142.    }
  143.  
  144.    public void startSet() {
  145.       this.field_0.init();
  146.       this.field_1.init();
  147.       this.field_2.init();
  148.       this.field_3 = 20;
  149.       this.life = 20;
  150.       playSt = true;
  151.       gameover = false;
  152.    }
  153. }
  154.